<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view');

class LettermanViewNewsletters extends JView
{
	function display( $tpl = null )
	{

		global $mainframe, $option;
		
		// Set up the layouts requirements
		$document = & JFactory::getDocument();
		$document->addStyleSheet('components/com_letterman/assets/letterman.css');

		$filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
		$filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
		$filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'n.created_time', 'cmd' );
		$filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
		$filter_campaign = $mainframe->getUserStateFromRequest( $option.'filter_campaign', 'filter_campaign', '', 'int' );
		$search	= $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
		$search	= JString::strtolower( $search );
		
		// Get the Data stuff
		$data = & $this->get( 'Data');
		$total = & $this->get( 'Total');
		$pagination = & $this->get( 'Pagination' );
		//$campaigns = & $this->model->getCampaigns();
		
		// Select list for Campaigns
		$javascript 	= 'onchange="document.adminForm.submit();"';
		$this->assignRef('campaigns', JHTML::_('select.genericlist',  $campaigns, 'filter_campaign', $javascript, intval( $filter_campaign ) ));
		
		// Add the toolbar items
		JToolBarHelper::title(   JText::_( 'Newsletter Manager' ), 'inbox.png' );
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
		JToolBarHelper::preview();
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();
		JToolBarHelper::deleteList();
		
		// send it through to the layout
		$this->assignRef('order_dir', $filter_order_Dir);
		$this->assignRef('order', $filter_order);
		$this->assignRef('state', JHTML::_('grid.state',  $filter_state ));
		$this->assignRef('search', $search);
		$this->assignRef('user',JFactory::getUser());
		$this->assignRef('data',$data);
		$this->assignRef('pagination',$pagination);

		parent::display($tpl);
	}
}
?>
